<%@ page contentType="text/html;charset=UTF-8" %>
<%@include file="/WEB-INF/jsp/common/taglibs.jspf"%>
<c:if test="${op eq '新增'}">
    <c:set var="icon" value="icon-file-alt"/>
</c:if>
<c:if test="${op eq '修改'}">
    <c:set var="icon" value="icon-edit"/>
</c:if>
<c:if test="${op eq '删除'}">
    <c:set var="icon" value="icon-trash"/>
</c:if>
<div class="page-content">
    <%--@elvariable id="m" type="com.bfl.sa.showcase.move.entity.Move"--%>
    <form:form id="editForm" method="post" commandName="m" cssClass="form-horizontal">
        <es:showGlobalError commandName="m"/>
        <form:hidden path="id"/>
        <div class="form-group">
            <form:label path="name" cssClass="col-sm-3 control-label">名称</form:label>
            <div class="col-sm-9">
                <form:input path="name" cssClass="form-control input-sm validate[required]" placeholder="5到10个字母、数字、下划线"/>
            </div>
        </div>
        <c:if test="${op ne '新增'}">
            <div class="form-group">
                <form:label path="weight" cssClass="col-sm-3 control-label">权重</form:label>
                <div class="col-sm-9">
                    <form:input path="weight" type="number" cssClass="col-sm-5 input-sm" placeholder="请输入权重（数字越大，权重越高）"/>
                    <span class="help-inline col-sm-7"><span class="middle">如果不填，默认最高优先级</span></span>
                </div>
            </div>
        </c:if>
        <div class="form-group">
            <form:label path="show" cssClass="col-sm-3 control-label">是否显示：</form:label>
            <div class="col-sm-9 radio">
                <form:radiobuttons path="show" items="${booleanList}" itemLabel="info" itemValue="value" cssClass="ace validate[required]"/>
            </div>
        </div>
        <div class="btn-group-sm center">
            <button type="button" class="btn btn-info">
                <i class="${icon}"></i>${op}
            </button>
            <a href="javascript:$.app.close();" class="btn">
                <i class="icon-reply"></i>返回
            </a>
        </div>
    </form:form>
</div>
<script>
    $(function () {
        <c:choose>
        <c:when test="${op eq '删除'}">
        //删除时不验证 并把表单readonly
        $.app.readonlyForm($("#editForm"), false);
        </c:when>
        <c:when test="${op eq '查看'}">
        $.app.readonlyForm($("#editForm"), true);
        </c:when>
            <c:otherwise>
                $("#editForm").validationEngine();
                <es:showFieldError commandName="m"/>
            </c:otherwise>
        </c:choose>
    });
</script>
